define(function(require){
var $=require("jq.js");
// 载入
var Dialog=require("pz_use_dialog.js");

$(".conture-btn").on("click",function(){
	var orderID = $(this).attr('orderid');
	var state = $(this).attr('state');
	var params = {};
	params['ColumnID'] = 1713;
	params['orderId'] = orderID;
	params['typeid'] = 1;
	params['valueid'] = 7;
	params[state] = 4;
	params['elemId'] = state;
		var tips=new Dialog({
			  type:"confirm",
			  text:"提示信息",
			  tipsText:"你确定要签收订单吗？",
			  buttonSureText:"确定", 
			  buttonCancelText:"暂不", 
			  callBack:function(){         //回调函数
				  $.get("/vipCente/frontQianShowOrder.do",params,function(data){
						var success = data.success;
						if(success != 1){
							var tips=new Dialog({
								  type:"tips",
								  text:data.message,
								  delay:2
								  });
						}else{
							var tips=new Dialog({
									  type:"alert",
									  text:"提示",
									  tipsText:"签收成功！",
									  callBack:function(){
										  window.location.reload();
									  },
									  mask:0.3
									 });	
						};
					},"json");
			  },
			  mask:0.3,
			  isDrag:true
			  });
});

$(".later-btn").on("click",function(){
	var delaySign = $(this).attr('delaySign');
	var orderId = $(this).attr('orderId');
	var params = {};
	params['orderId'] = orderId;
	if(delaySign=='true'){
		var tips=new Dialog({
			  type:"confirm",
			  text:"提示信息",
			  tipsText:"您可以延长收回时间10天，您是否确认延长",
			  buttonSureText:"确定", 
			  buttonCancelText:"暂不", 
			  callBack:function(){         //回调函数
				  $.get("/vipCente/delaySignOrder.do",params,function(data){
						var success = data.success;
						if(success != 1){
							var tips=new Dialog({
								  type:"tips",
								  text:data.message,
								  delay:2
								  });
						}else{
							var tips=new Dialog({
									  type:"alert",
									  text:"提示",
									  tipsText:"延迟成功！",
									  callBack:function(){
										  window.location.reload();
									  },
									  mask:0.3
									 });	
						};
					},"json");
			  },
			  mask:0.3,
			  isDrag:true
			  });
	}else{
		var tips=new Dialog({
			  type:"confirm",
			  text:"提示信息",
			  tipsText:"您可以在离超时结束还剩最后3天时，申请延长确认收货时间",
			  buttonSureText:"确定", 
			  mask:0.3,
			  isDrag:true
			  });
	}
		
});

var date = $("#date-show").attr("date");
var type= $("#date-show").attr("type");
var intDiff = parseInt(date);//倒计时总秒数量
timer(intDiff);
//倒计时
function timer(intDiff){
    window.setInterval(function(){
    var day=0,
        hour=0,
        minute=0,
        second=0;//时间默认值        
    if(intDiff > 0){
        day = Math.floor(intDiff / (60 * 60 * 24));
        hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
        minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
        second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
    }
    if (minute <= 9) minute = '0' + minute;
    if (second <= 9) second = '0' + second;

    $('#date-show').html(day+"天"+hour+"小时"+minute+"分"+second+"秒");

    intDiff--;
    }, 1000);
} 
});
